﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Reflection;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using Entity;
using Oracle.DataAccess.Client;
using Platform.Configuration;
using Platform.Data;
using Platform.Log;
using WebCalendar;
using BLL.Access;

namespace BLL
{
    /// <summary>
    /// 用于接收存储过程执行状态码与消息,存储过程中需要两个对应输出参数:V_RSNO OUT VARCHAR2,V_RSMSG OUT VARCHAR2
    /// </summary>
    public class DBResult
    {
        public string RSNO { get; set; }
        public string RSMSG { get; set; }

        public bool IsSuccess
        {
            get
            {
                return int.Parse(RSNO) > 0;
            }
        }
    }
    public class BusinessTool
    {
        #region 私有变量
        /// <summary>
        /// sphelper 对象
        /// </summary> 
        private static readonly SpHelper _spHelper = new SpHelper();
        #endregion

        #region 公共变量

        /// <summary>
        ///     下拉框 默认选项
        /// </summary>
        public static string _ddlDefaultStr = "--请选择--";

        public static int WType
        {
            get
            {
                //暂时设置为2 默认地下水
                return HttpContext.Current.Session["WType"] == null ? -1 : Convert.ToInt32(HttpContext.Current.Session["WType"]);
            }
        }

        //取水管理块默认设为98 用于生成来函号
        public static string QSGLKH
        {
            get
            {
                return "98";
            }
        }

        public enum eWType
        {
            计划水 = 0,
            地下水 = 2,
            地表水 = 1
        }


        #endregion

        //        /// <summary>
        //        ///     四舍五入
        //        /// </summary>
        //        /// <param name="value">数值</param>
        //        /// <param name="digit">保留位数</param>
        //        /// <returns></returns>
        //        public static double C1Round(double value, int digit)
        //        {
        //            var vt = Math.Pow(10, digit);
        //            var vx = value*vt;

        //            vx += 0.5;
        //            return (Math.Floor(vx)/vt);
        //        }

        //        /// <summary>
        //        ///     根据ID获取对应表的行记录
        //        /// </summary>
        //        /// <param name="tableName">表名</param>
        //        /// <param name="id">主键ID</param>
        //        /// <returns>表的行记录</returns>
        //        public DataTable GetDataTable(string tableName, int id, SqlTransaction tran)
        //        {
        //            var spName = "_Select" + tableName;
        //            var storedParams = SqlHelperParameterCache.GetSpParameterSet(ConfigHelper.PlatformConnString, spName);
        //            storedParams[0].Value = id;
        //            DataSet ds = null;
        //            if (null == tran)
        //                ds = SqlHelper.ExecuteDataset(ConfigHelper.PlatformConnString, CommandType.StoredProcedure, spName,
        //                    storedParams);
        //            else
        //                ds = SqlHelper.ExecuteDataset(tran, CommandType.StoredProcedure, spName, storedParams);
        //            if (null == ds)
        //            {
        //                return null;
        //            }
        //            return ds.Tables[0];
        //        }

        //        public static void AddRowNumber(DataTable dt)
        //        {
        //            dt.Columns.Add(new DataColumn("RowNumber", typeof (int)));
        //            for (var i = 0; i < dt.Rows.Count; i++)
        //            {
        //                dt.Rows[i][dt.Columns.Count - 1] = i + 1;
        //            }
        //        }

        //        /// <summary>
        //        ///     通过用户名得到账号
        //        /// </summary>
        //        /// <param name="name">用户名</param>
        //        /// <returns>账号</returns>
        //        public static string GetAccountByName(string name)
        //        {
        //            string account;
        //            if (Utility.ToString(name) == "")
        //            {
        //                return "";
        //            }

        //            #region Local Var

        //            var sql = "";
        //            var param = new SqlParameter[1];

        //            #endregion

        //            #region GetParams

        //            sql = @"Select Account From AS_UserInfo where UserName = @Name";

        //            param[0] = new SqlParameter("@Name", SqlDbType.NVarChar, 100);
        //            param[0].Value = name;

        //            #endregion

        //            try
        //            {
        //                account = SqlHelper.ExecuteScalar(PlatformConn, CommandType.Text, sql, param).ToString();
        //            }
        //            catch
        //            {
        //                return name;
        //            }
        //            return account;
        //        }

        //        /// <summary>
        //        ///     通过账号得到用户名
        //        /// </summary>
        //        /// <param name="account">账号</param>
        //        /// <returns>用户名</returns>
        //        public static string GetNameByAccount(string account)
        //        {
        //            var name = "";
        //            try
        //            {
        //                if (Utility.ToString(account) != "" && Utility.ToString(account) != "0")
        //                {
        //                    #region Local Var

        //                    var sql = "";
        //                    var param = new SqlParameter[1];

        //                    #endregion

        //                    #region GetParams

        //                    sql = @"Select UserName From AS_UserInfo where account = @account";

        //                    param[0] = new SqlParameter("@account", SqlDbType.NVarChar, 100);
        //                    param[0].Value = account;

        //                    #endregion

        //                    name = SqlHelper.ExecuteScalar(PlatformConn, CommandType.Text, sql, param).ToString();
        //                }
        //            }
        //            catch (Exception ex)
        //            {
        //                SystemLog.SaveLogInfo(ex.Message, account, "GetNameByAccount");
        //                return account;
        //            }
        //            return name;
        //        }

        //        /// <summary>
        //        ///     根据wordsID绑定DropDownList
        //        /// </summary>
        //        /// <param name="wordsID">词语编号</param>
        //        /// <param name="ddl">DropDownList ID</param>
        //        /// <param name="flag">false:系统词语表 true:用户词语表</param>
        //        /// <param name="DefaultStr">默认文字</param>
        //        public static void BindDropDownListByWordsID(int wordsID, DropDownList ddl, bool flag, string DefaultStr)
        //        {
        //            BindDropDownListByWordsID(wordsID, ddl, flag);
        //            ddl.Items.Insert(0, new ListItem(DefaultStr, "0")); //default str
        //        }

        //        /// <summary>
        //        ///     根据wordsID绑定DropDownList
        //        /// </summary>
        //        /// <param name="wordsID">词语编号</param>
        //        /// <param name="ddl">DropDownList ID</param>
        //        /// <param name="flag">false:系统词语表 true:用户词语表</param>
        //        /// <param name="DefaultStr">默认文字</param>
        //        public static void BindDropDownListByWordsID(int wordsID, string wordsRemark, DropDownList ddl, bool flag,
        //            string DefaultStr)
        //        {
        //            BindDropDownListByWordsID(wordsID, wordsRemark, ddl, flag);
        //            ddl.Items.Insert(0, new ListItem(DefaultStr, "0")); //default str
        //        }

        //        /// <summary>
        //        ///     根据wordsID绑定DropDownList
        //        /// </summary>
        //        /// <param name="wordsID">词语编号</param>
        //        /// <param name="ddl">DropDownList ID</param>
        //        /// <param name="flag">false:系统词语表 true:用户词语表</param>
        //        public static void BindDropDownListByWordsID(int wordsID, DropDownList ddl, bool flag)
        //        {
        //            #region Local Var

        //            var sql = "";

        //            var param = new SqlParameter[2];

        //            #endregion

        //            #region GetParams

        //            sql = @"   Select WordsContent,WordsID,WordsValue From S_Words
        //                       WHERE BelongID=@WordsID  and IsActive=1 order by SortID
        //                       ";

        //            param[0] = new SqlParameter("@WordsID", SqlDbType.Int);


        //            param[0].Value = wordsID;

        //            #endregion

        //            #region wangyanqing 修改

        //            //先清空DropDownList
        //            ddl.Items.Clear();

        //            #region old methods

        //            #endregion

        //            var ds = SqlHelper.ExecuteDataset(PlatformConn, CommandType.Text, sql, param);
        //            ListItem li;
        //            if (ds.Tables.Count > 0)
        //            {
        //                for (var i = 0; i < ds.Tables[0].Rows.Count; i++)
        //                {
        //                    li = new ListItem(ds.Tables[0].Rows[i]["WordsContent"].ToString(),
        //                        ds.Tables[0].Rows[i]["WordsValue"].ToString());
        //                    //li.Attributes["WordsRemark"] = ds.Tables[0].Rows[i]["WordsRemark"].ToString();
        //                    ddl.Items.Add(li);
        //                }
        //            }

        //            #endregion
        //        }

        //        /// <summary>
        //        ///     根据wordsID绑定DropDownList
        //        /// </summary>
        //        /// <param name="wordsID">词语编号</param>
        //        /// <param name="ddl">DropDownList ID</param>
        //        /// <param name="flag">false:系统词语表 true:用户词语表</param>
        //        /// <param name="DefaultStr">默认文字</param>
        //        public static void BindDropDownListByWordsRemark(int wordsID, string wordsRemark, DropDownList ddl, bool flag,
        //            string DefaultStr)
        //        {
        //            BindDropDownListByWordsRemark(wordsID, wordsRemark, ddl, flag);
        //            ddl.Items.Insert(0, new ListItem(DefaultStr, "0")); //default str
        //        }

        //        /// <summary>
        //        ///     根据belondId 和 wordsValue 得到 wordsContent
        //        /// </summary>
        //        /// <param name="belongId"></param>
        //        /// <param name="wordsValue"></param>
        //        /// <returns></returns>
        //        public static string GetWordsContent(int belongId, string wordsValue)
        //        {
        //            var wordsContent = string.Empty;

        //            var dtWords = WordsHelper.GetXiaoLeiListByWordsID(belongId);
        //            foreach (var r in dtWords.Select("WordsValue='" + wordsValue + "'"))
        //            {
        //                wordsContent = r["WordsContent"].ToString();
        //            }
        //            return wordsContent;
        //        }

        //        /// <summary>
        //        ///     根据wordID绑定Lable<weifu>
        //        /// </summary>
        //        /// <param name="wordsID">词语编号</param>
        //        /// <param name="lbl">Lable ID</param>
        //        /// <param name="flag">false:系统词语表 true:用户词语表</param>
        //        public static void BindLableByWordsID(int wordsID, Label lbl, bool flag)
        //        {
        //            #region Local Var

        //            var sql = "";
        //            var param = new SqlParameter[2];

        //            #endregion

        //            #region GetParams

        //            sql = @"   Select WordsContent,WordsID,WordsValue From S_Words
        //                       WHERE BelongID=@WordsID   and IsActive=1 order by SortID
        //                       ";

        //            param[0] = new SqlParameter("@WordsID", SqlDbType.Int);


        //            param[0].Value = wordsID;

        //            #endregion

        //            #region  BindText

        //            lbl.Text = string.Empty + "<br/>&nbsp;";

        //            var ds = SqlHelper.ExecuteDataset(PlatformConn, CommandType.Text, sql, param);

        //            if ((ds.Tables.Count > 0) && (ds.Tables[0].Rows.Count > 0))
        //            {
        //                for (var i = 0; i < ds.Tables[0].Rows.Count; i++)
        //                {
        //                    lbl.Text += ds.Tables[0].Rows[i]["WordsValue"] + "<br/>&nbsp;";
        //                }
        //            }

        //            #endregion
        //        }

        //        /// <summary>
        //        ///     根据wordsRemark绑定DropDownList
        //        /// </summary>
        //        /// <param name="wordsID">词语编号</param>
        //        /// <param name="ddl">DropDownList ID</param>
        //        /// <param name="flag">false:系统词语表 true:用户词语表</param>
        //        public static void BindDropDownListByWordsRemark(int wordsID, string wordsRemark, DropDownList ddl, bool flag)
        //        {
        //            #region Local Var

        //            var sql = "";
        //            var param = new SqlParameter[3];

        //            #endregion

        //            #region GetParams

        //            sql = @"   Select WordsContent,WordsID,WordsValue From S_Words
        //                       WHERE BelongID=@WordsID and WordsRemark=@WordsRemark and IsActive=1 order by SortID
        //                       ";

        //            param[0] = new SqlParameter("@WordsID", SqlDbType.Int);
        //            param[1] = new SqlParameter("@WordsRemark", SqlDbType.VarChar, 20);

        //            param[0].Value = wordsID;
        //            param[1].Value = wordsRemark;

        //            #endregion

        //            #region wangyanqing 修改

        //            //先清空DropDownList
        //            ddl.Items.Clear();


        //            var ds = SqlHelper.ExecuteDataset(PlatformConn, CommandType.Text, sql, param);
        //            ListItem li;
        //            if (ds.Tables.Count > 0)
        //            {
        //                for (var i = 0; i < ds.Tables[0].Rows.Count; i++)
        //                {
        //                    li = new ListItem(ds.Tables[0].Rows[i]["WordsContent"].ToString(),
        //                        ds.Tables[0].Rows[i]["WordsValue"].ToString());
        //                    //li.Attributes["WordsRemark"] = ds.Tables[0].Rows[i]["WordsRemark"].ToString();
        //                    ddl.Items.Add(li);
        //                }
        //            }

        //            #endregion
        //        }

        //        /// <summary>
        //        ///     用于配置信息表绑定下拉框
        //        /// </summary>
        //        /// <param name="I_PeiZhiID"></param>
        //        /// <param name="ddl"></param>
        //        /// <param name="DefaultStr"></param>
        //        public static void BindDropDownListByWordsID_PZ(int I_PeiZhiID, string ShowMemberName, DropDownList ddl,
        //            string DefaultStr)
        //        {
        //            #region Local Var

        //            var sql = "";
        //            var param = new SqlParameter[1];

        //            #endregion

        //            #region GetParams

        //            sql = "   Select I_PeiZhiID," + ShowMemberName +
        //                  " From S_PeiZhiXX WHERE I_SuoShuID=@I_PeiZhiID and I_ZhuangTai=0 order by I_PaiXuID";

        //            param[0] = new SqlParameter("@I_PeiZhiID", SqlDbType.Int);
        //            param[0].Value = I_PeiZhiID;

        //            #endregion

        //            #region

        //            //先清空DropDownList
        //            ddl.Items.Clear();

        //            #region old methods

        //            #endregion

        //            var ds = SqlHelper.ExecuteDataset(BusinessConn, CommandType.Text, sql, param);
        //            ListItem li;
        //            if (ds.Tables.Count > 0)
        //            {
        //                for (var i = 0; i < ds.Tables[0].Rows.Count; i++)
        //                {
        //                    li = new ListItem(ds.Tables[0].Rows[i][ShowMemberName].ToString(),
        //                        ds.Tables[0].Rows[i]["I_PeiZhiID"].ToString());
        //                    //li.Attributes["WordsRemark"] = ds.Tables[0].Rows[i]["WordsRemark"].ToString();
        //                    ddl.Items.Add(li);
        //                }
        //            }

        //            ddl.Items.Insert(0, new ListItem(DefaultStr, "0"));

        //            #endregion
        //        }

        //        /// <summary>
        //        ///     根据wordsID,wordsRemark绑定DropDownList
        //        /// </summary>
        //        /// <param name="wordsID">词语编号</param>
        //        /// <param name="wordsRemark">词语备注</param>
        //        /// <param name="ddl">DropDownList ID</param>
        //        /// <param name="flag">false:系统词语表 true:用户词语表</param>
        //        public static void BindDropDownListByWordsID(int wordsID, string wordsRemark, DropDownList ddl, bool flag)
        //        {
        //            #region Local Var

        //            var sql = "";
        //            var param = new SqlParameter[3];

        //            #endregion

        //            #region GetParams

        //            sql = @"   Select WordsContent,WordsValue From S_Words
        //                       WHERE BelongID=@WordsID  and wordsRemark=@wordsRemark and IsActive=1 order by SortID
        //                       ";

        //            param[0] = new SqlParameter("@WordsID", SqlDbType.Int);
        //            param[1] = new SqlParameter("@wordsRemark", SqlDbType.NVarChar, 50);

        //            param[0].Value = wordsID;
        //            param[1].Value = wordsRemark;

        //            #endregion

        //            #region wangyanqing 修改

        //            //先清空DropDownList
        //            ddl.Items.Clear();

        //            #region old methods

        //            #endregion

        //            var ds = SqlHelper.ExecuteDataset(PlatformConn, CommandType.Text, sql, param);
        //            ListItem li;
        //            if (ds.Tables.Count > 0)
        //            {
        //                for (var i = 0; i < ds.Tables[0].Rows.Count; i++)
        //                {
        //                    li = new ListItem(ds.Tables[0].Rows[i]["WordsContent"].ToString(),
        //                        ds.Tables[0].Rows[i]["WordsValue"].ToString());
        //                    //li.Attributes["WordsRemark"] = ds.Tables[0].Rows[i]["WordsRemark"].ToString();
        //                    ddl.Items.Add(li);
        //                }
        //            }

        //            #endregion
        //        }

        //        /// <summary>
        //        ///     Bind Empty Grid Header
        //        ///     根据一个object 绑定空表头 可以是一个实体，也可以是一个datatable
        //        ///     Eg:
        //        ///     <asp:GridView ID="GridView1" runat="server">
        //        ///     </asp:GridView>
        //        ///     protected override void Render(HtmlTextWriter writer)
        //        ///     {
        //        ///     BLL.BusinessTool.BuildNoRecords(GridView1,new Entity.Share_ChargePlan());
        //        ///     base.Render(writer);
        //        ///     }
        //        /// </summary>
        //        /// <param name="GV"></param>
        //        /// <param name="DataSource"></param>
        //        public static void BuildNoRecords(GridView GV, object DataSource)
        //        {
        //            if (GV.Rows.Count == 0)
        //            {
        //                if (DataSource is DataSet)
        //                {
        //                    _BusinessTool.BuildNoRecords(GV, ((DataSet) DataSource).Tables[0]);
        //                }
        //                else if (DataSource is DataTable)
        //                {
        //                    _BusinessTool.BuildNoRecords(GV, ((DataTable) DataSource));
        //                }
        //                else
        //                {
        //                    _BusinessTool.BuildNoRecords(GV, DataSource, true);
        //                }
        //            }
        //        }

        //        /// <summary>
        //        ///     通过业务类型和数据库中记录的值得到Plamform.S_Words中配置的WordsContent
        //        /// </summary>
        //        /// <param name="name">业务类型</param>
        //        /// <param name="name">值</param>
        //        /// <returns>业务名称</returns>
        //        public static string GetWordsContent(string wordsType, int wordsValue)
        //        {
        //            if (Utility.ToString(wordsType) == "")
        //            {
        //                return "";
        //            }

        //            #region Local Var

        //            var sql = "";
        //            var param = new SqlParameter[2];

        //            #endregion

        //            #region GetParams

        //            sql = @" Select WordsContent From S_Words 
        //                    Where IsActive = 1 And WordsID = @I_value 
        //                    and BelongID = (Select WordsID From S_Words 
        //					    Where BelongID = 0 and WordsValue = @S_type)";

        //            param[0] = new SqlParameter("@S_type", SqlDbType.NVarChar, 50);
        //            param[1] = new SqlParameter("@I_value", SqlDbType.Int);
        //            param[0].Value = wordsType;
        //            param[1].Value = wordsValue;

        //            #endregion

        //            var wordsContent = SqlHelper.ExecuteScalar(PlatformConn, CommandType.Text, sql, param).ToString();
        //            return wordsContent;
        //        }

        //        /// <summary>
        //        ///     通过备注和BelongID得到WordsContent
        //        /// </summary>
        //        /// <param name="wordsID">业务wordsID</param>
        //        /// <param name="wordsRemark">业务备注</param>
        //        /// <returns></returns>
        //        public static string GetWordsContentByWordsID(int wordsID, string wordsRemark)
        //        {
        //            #region Local Var

        //            var sql = "";
        //            var param = new SqlParameter[2];

        //            #endregion

        //            #region GetParams

        //            sql = @"   Select WordsContent,WordsValue From S_Words
        //                       WHERE BelongID=@WordsID  and wordsRemark=@wordsRemark and IsActive=1 order by SortID
        //                       ";

        //            param[0] = new SqlParameter("@WordsID", SqlDbType.Int);
        //            param[1] = new SqlParameter("@wordsRemark", SqlDbType.NVarChar, 50);

        //            param[0].Value = wordsID;
        //            param[1].Value = wordsRemark;

        //            #endregion

        //            var wordsContent = "";
        //            if (SqlHelper.ExecuteScalar(PlatformConn, CommandType.Text, sql, param) != null)
        //            {
        //                wordsContent = SqlHelper.ExecuteScalar(PlatformConn, CommandType.Text, sql, param).ToString();
        //            }
        //            return wordsContent;
        //        }

        //        /// <summary>
        //        ///     根据wordsContent得到wordsID
        //        /// </summary>
        //        /// <param name="wordsContent">wordsContent</param>
        //        /// <param name="belongID"></param>
        //        /// <param name="flag">false:系统词语表true:用户词语表</param>
        //        /// <returns>wordsID</returns>
        //        public static int GetWordsValue(string wordsContent, int belongID, bool flag)
        //        {
        //            var wordsID = -1;

        //            #region Local Var

        //            var sql = "";
        //            var param = new SqlParameter[3];

        //            #endregion

        //            #region GetParams

        //            sql = @"   Select WordsID From S_Words
        //                       WHERE BelongID=@BelongID And WordsContent = @WordsContent 
        //                       ";

        //            param[0] = new SqlParameter("@WordsContent", SqlDbType.NVarChar);
        //            param[1] = new SqlParameter("@BelongID", SqlDbType.Int);


        //            param[0].Value = wordsContent;
        //            param[1].Value = belongID;

        //            var ds = SqlHelper.ExecuteDataset(PlatformConn, CommandType.Text, sql, param);
        //            if (ds.Tables[0].Rows.Count > 0)
        //            {
        //                wordsID = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString());
        //            }
        //            return wordsID;

        //            #endregion
        //        }

        //        public static int GetWordsValue(string wordsContent, int belongID, bool flag, bool IsOwenDataBase)
        //        {
        //            var wordsID = -1;
        //            if (!IsOwenDataBase)
        //            {
        //                #region Local Var

        //                var sql = "";
        //                var param = new SqlParameter[3];

        //                #endregion

        //                #region GetParams

        //                sql = @"   Select WordsID From  QYHYWaterXZ_Platform.dbo.S_Words
        //                       WHERE BelongID=@BelongID And WordsContent = @WordsContent 
        //                       ";

        //                param[0] = new SqlParameter("@WordsContent", SqlDbType.NVarChar);
        //                param[1] = new SqlParameter("@BelongID", SqlDbType.Int);

        //                param[0].Value = wordsContent;
        //                param[1].Value = belongID;

        //                var ds = SqlHelper.ExecuteDataset(PlatformConn, CommandType.Text, sql, param);
        //                if (ds.Tables[0].Rows.Count > 0)
        //                {
        //                    wordsID = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString());
        //                }
        //            }
        //            return wordsID;

        //            #endregion
        //        }

        //        /// created by jiangjun on 2008-6-1
        //        /// <summary>
        //        ///     根据wordsID得到wordsContent
        //        /// </summary>
        //        /// <param name="WordsID">wordsID</param>
        //        /// <param name="belongID">所属大类</param>
        //        /// <param name="flag">false:系统词语表true:用户词语表</param>
        //        /// <returns>wordsContent</returns>
        //        public static string GetwordsContent(int WordsID, int belongID, bool flag)
        //        {
        //            var wordsContent = "";

        //            #region Local Var

        //            var sql = "";
        //            var param = new SqlParameter[3];

        //            #endregion

        //            #region GetParams

        //            sql = @" Select WordsContent From S_Words
        //                       WHERE WordsID =@WordsID And BelongID=@BelongID ";
        //            param[0] = new SqlParameter("@WordsID", SqlDbType.Int);
        //            param[1] = new SqlParameter("@BelongID", SqlDbType.Int);

        //            param[0].Value = WordsID;
        //            param[1].Value = belongID;

        //            var ds = SqlHelper.ExecuteDataset(PlatformConn, CommandType.Text, sql, param);
        //            if (ds.Tables[0].Rows.Count > 0)
        //            {
        //                wordsContent = ds.Tables[0].Rows[0][0].ToString();
        //            }
        //            return wordsContent;

        //            #endregion
        //        }

        //        /// <summary>
        //        ///     created by weifu on 2010-6-4
        //        ///     根据wordsID得到wordsRemark
        //        /// </summary>
        //        /// <param name="WordsID">小类WordsID</param>
        //        /// <param name="belongID">所属大类</param>
        //        /// <param name="flag">false:系统词语表true:用户词语表</param>
        //        /// <returns>wordsRemark</returns>
        //        public static string GetWordsRemark(int WordsID, int belongID, bool flag)
        //        {
        //            var wordsRemark = "";

        //            #region Local Var

        //            var sql = "";
        //            var param = new SqlParameter[3];

        //            #endregion

        //            #region GetParams

        //            sql = @" Select WordsRemark From S_Words
        //                       WHERE WordsID =@WordsID And BelongID=@BelongID";
        //            param[0] = new SqlParameter("@WordsID", SqlDbType.Int);
        //            param[1] = new SqlParameter("@BelongID", SqlDbType.Int);

        //            param[0].Value = WordsID;
        //            param[1].Value = belongID;

        //            wordsRemark = SqlHelper.ExecuteScalar(PlatformConn, CommandType.Text, sql, param).ToString();
        //            return wordsRemark;

        //            #endregion
        //        }

        //        /// <summary>
        //        ///     根据受理单位values得到单位的配置信息
        //        /// </summary>
        //        /// <param name="wordsValue">单位values</param>
        //        /// <returns>DataTable</returns>
        //        public static DataTable GetShouLiDanWeiInfo(int wordsValue)
        //        {
        //            var belongId = 36;
        //            if (wordsValue == 1) //安装公司
        //            {
        //                belongId = 9;
        //            }
        //            else if (wordsValue == 2) //水务
        //            {
        //                belongId = 36;
        //            }
        //            return WordsHelper.GetXiaoLeiListByWordsID(belongId);
        //        }

        //        /// <summary>
        //        ///     根据单位Id得到单位信息，联系电话、传真
        //        /// </summary>
        //        /// <param name="shouLiDwId">单位Id</param>
        //        /// <param name="lianXiFs">联系电话、传真（输出参数）</param>
        //        /// <param name="danWeiXx">单位名称</param>
        //        public static void GetShouLiDanWeiDhCz(int shouLiDwId, out string lianXiFs, out string danWeiXx)
        //        {
        //            lianXiFs = string.Empty; //联系方式
        //            danWeiXx = string.Empty; //单位信息
        //            var dtWords =
        //                GetShouLiDanWeiInfo(shouLiDwId);
        //            foreach (var r in dtWords.Select())
        //            {
        //                switch (Convert.ToInt32(r["WordsValue"].ToString()))
        //                {
        //                    case 1:
        //                        danWeiXx = r["WordsContent"].ToString();
        //                        break;
        //                    case 5:
        //                        if (!string.IsNullOrEmpty(r["WordsContent"].ToString()))
        //                        {
        //                            lianXiFs += "电话：" + r["WordsContent"] + " ；";
        //                        }
        //                        break;

        //                    case 6:
        //                        if (!string.IsNullOrEmpty(r["WordsContent"].ToString()))
        //                        {
        //                            lianXiFs += "传真：" + r["WordsContent"] + " ；";
        //                        }
        //                        break;
        //                }
        //            }
        //            lianXiFs = lianXiFs.Substring(0, lianXiFs.Length - 1);
        //        }

        //        /// <summary>
        //        ///     enable or disable the control's contorls(one level)
        //        /// </summary>
        //        /// <param name="container"></param>
        //        /// <param name="enable"></param>
        //        public static void ControlEnable(Control container, bool enable)
        //        {
        //            foreach (Control var in container.Controls)
        //            {
        //                if (var is TextBox)
        //                {
        //                    ((TextBox) var).Enabled = enable;
        //                }
        //                if (var is CheckBox)
        //                {
        //                    ((CheckBox) var).Enabled = enable;
        //                }
        //                if (var is DropDownList)
        //                {
        //                    ((DropDownList) var).Enabled = enable;
        //                }
        //                if (var is CalendarPicker)
        //                {
        //                    ((CalendarPicker) var).Enabled = enable;
        //                }
        //                if (var is Button)
        //                {
        //                    ((Button) var).Enabled = enable;
        //                }
        //                if (var is HtmlInputButton)
        //                {
        //                    if (!enable)
        //                    {
        //                        ((HtmlInputButton) var).Attributes["disabled"] = "'disabled'";
        //                    }
        //                    else
        //                    {
        //                        ((HtmlInputButton) var).Attributes.Remove("disabled");
        //                    }
        //                }

        //                    #region process GridView

        //                else if (var is GridView)
        //                {
        //                    var gv = ((GridView) var); //遍历到的GV
        //                    var _DataControlFieldCollection = gv.Columns; //GV的列集合
        //                    for (var i = 0; i < _DataControlFieldCollection.Count; i++) //遍历gv的列
        //                    {
        //                        var _DataControlField = _DataControlFieldCollection[i];
        //                        var currentState = enable; //GRIDVIEW中控件用的状态
        //                        for (var n = 0; n < gv.Rows.Count; n++) //遍历这列中的行
        //                        {
        //                            if (gv.Rows[n].RowType == DataControlRowType.DataRow) //如果是真行的话
        //                            {
        //                                foreach (Control item in gv.Rows[n].Cells[i].Controls) //遍历这行单元格中的控件
        //                                {
        //                                    if (item is LinkButton)
        //                                    {
        //                                        ((LinkButton) item).Enabled = currentState;
        //                                        ((LinkButton) item).OnClientClick = "";
        //                                    }
        //                                    else if (item is Button)
        //                                    {
        //                                        ((Button) item).Enabled = currentState;
        //                                        ((Button) item).OnClientClick = "";
        //                                    }
        //                                    else if (item is CheckBox)
        //                                    {
        //                                        ((CheckBox) item).Enabled = currentState;
        //                                        ((CheckBox) item).Attributes["onclick"] = "";
        //                                    }
        //                                }
        //                            }
        //                        }
        //                    }
        //                    return; //如果是grid直接return
        //                }

        //                #endregion

        //                ControlEnable(var, enable);
        //            }
        //        }

        //        /// <summary>
        //        ///     Label显示N个字符，超出字符数toolsTip显示
        //        /// </summary>
        //        /// <param name="lbl">Label</param>
        //        /// <param name="text">原始字符</param>
        //        /// <param name="showLength">显示字符数，超出“。。。”</param>
        //        public static void ShowLabelTooltipAndText(Label lbl, string text, int showLength)
        //        {
        //            text = text.Trim();
        //            if (text.Length > showLength)
        //            {
        //                lbl.ToolTip = text;
        //                lbl.Text = text.Substring(0, showLength) + "...";
        //            }
        //            else
        //            {
        //                lbl.Text = text;
        //            }
        //        }

        //        /// <summary>
        //        ///     根据角色绑定下拉用户信息
        //        /// </summary>
        //        /// <param name="roleName">角色名</param>
        //        /// <param name="zhanDianBh">站点编号</param>
        //        /// <param name="defaultString">默认文字</param>
        //        public static void BindDropDownListUserByRoleName(DropDownList ddl, string roleName, string zhanDianBh,
        //            string defaultString)
        //        {
        //            //先清空DropDownList
        //            ddl.Items.Clear();

        //            var ds = SpHelper.GetUserInfoByRoleName(roleName, zhanDianBh, null);
        //            ListItem li;
        //            if (ds.Tables.Count > 0)
        //            {
        //                for (var i = 0; i < ds.Tables[0].Rows.Count; i++)
        //                {
        //                    li = new ListItem(ds.Tables[0].Rows[i]["UserName"].ToString(),
        //                        ds.Tables[0].Rows[i]["Account"].ToString());
        //                    ddl.Items.Add(li);
        //                }
        //            }
        //            ddl.Items.Insert(0, new ListItem(defaultString, "0")); //default str
        //        }

        //        /// <summary>
        //        ///     根据角色绑定用户，排除当前用户
        //        /// </summary>
        //        /// <param name="ddl"></param>
        //        /// <param name="roleName"></param>
        //        /// <param name="userAccount"></param>
        //        /// <param name="defaultString"></param>
        //        public static void BindDDLUserByRoleNameExceptCurUser(DropDownList ddl, string roleName, string userAccount,
        //            string defaultString)
        //        {
        //            //先清空DropDownList
        //            ddl.Items.Clear();

        //            var ds = SpHelper.GetUserInfoByRoleName(roleName, "", null);
        //            ListItem li;
        //            if (ds.Tables.Count > 0)
        //            {
        //                foreach (var r in ds.Tables[0].Select("Account<>'" + userAccount + "'"))
        //                {
        //                    li = new ListItem(r["UserName"].ToString(), r["Account"].ToString());
        //                    ddl.Items.Add(li);
        //                }

        //                ddl.Items.Insert(0, new ListItem(defaultString, "0")); //default str
        //            }
        //        }

        //        /// <summary>
        //        ///     根据用户账号得到所属角色
        //        /// </summary>
        //        /// <param name="userAccount"></param>
        //        /// <returns></returns>
        //        public static DataTable GetRoleNameByUserAccount(string userAccount)
        //        {
        //            var ds = SpHelper.GetRoleNameByUserAccount(userAccount, null);

        //            return ds.Tables.Count > 0 ? ds.Tables[0] : null;
        //        }

        //        public static void BindCheckBoxListByWordsID(int wordsID, CheckBoxList cbl)
        //        {
        //            var sql =
        //                @"Select WordsContent,WordsID,WordsValue From S_Words WHERE BelongID=@WordsID  and IsActive=1 order by SortID";
        //            SqlParameter[] paras = {new SqlParameter("@WordsID", wordsID)};
        //            var ds = SqlHelper.ExecuteDataset(PlatformConn, CommandType.Text, sql, paras);
        //            if (ds != null && ds.Tables[0].Rows.Count > 0)
        //            {
        //                for (var i = 0; i < ds.Tables[0].Rows.Count; i++)
        //                {
        //                    cbl.Items.Add(new ListItem(ds.Tables[0].Rows[i]["WordsContent"].ToString(),
        //                        ds.Tables[0].Rows[i]["WordsValue"].ToString()));
        //                }
        //            }
        //        }

        //        /// <summary>
        //        ///     根据wordsID绑定DropDownList
        //        /// </summary>
        //        /// <param name="wordsID">词语编号</param>
        //        /// <param name="ddl">DropDownList ID</param>
        //        /// <param name="DefaultStr">默认文字</param>
        //        public static void BindDropDownListByWordsID(int wordsID, DropDownList ddl, string DefaultStr)
        //        {
        //            BindDropDownListByWordsID(wordsID, ddl);
        //            ddl.Items.Insert(0, new ListItem(DefaultStr, "0")); //default str
        //        }

        //        public static void BindRopDownListByWordsIDMaxDay(int wordsID, DropDownList ddl, string DefaultStr)
        //        {
        //            #region Local Var

        //            var sql = "";
        //            var param = new SqlParameter[1];

        //            #endregion

        //            #region GetParams

        //            sql = @"   Select WordsContent,WordsID,WordsValue From S_Words
        //                       WHERE BelongID=@WordsID  and IsActive=1 order by SortID
        //                       ";

        //            param[0] = new SqlParameter("@WordsID", SqlDbType.Int);


        //            param[0].Value = wordsID;

        //            #endregion

        //            #region 更新

        //            var ds = SqlHelper.ExecuteDataset(PlatformConn, CommandType.Text, sql, param);
        //            if (ds == null || ds.Tables[0].Rows.Count == 0) return;
        //            var maxday = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
        //            for (var i = 1; i <= maxday; i++)
        //            {
        //                ddl.Items.Add(new ListItem(i.ToString(), i.ToString()));
        //            }

        //            #endregion

        //            ddl.Items.Insert(0, new ListItem(DefaultStr, "0")); //default str
        //        }

        //        public static void BindDropDownListByWordsID(int wordsID, DropDownList ddl)
        //        {
        //            #region Local Var

        //            var sql = "";

        //            var param = new OracleParameter[1];

        //            #endregion

        //            #region GetParams

        //            sql = @"   Select WordsContent,WordsID,WordsValue From S_Words
        //                       WHERE BelongID=:WordsID  and IsActive=1 order by SortID
        //                       ";

        //            param[0] = new OracleParameter("WordsID", OracleDbType.Int32);


        //            param[0].Value = wordsID;

        //            #endregion

        //            #region wangyanqing 修改

        //            //先清空DropDownList
        //            ddl.Items.Clear();

        //            var ds = OracleHelper.ExecuteDataset(PlatformConn, CommandType.Text, sql, param);
        //            ListItem li;
        //            if (ds.Tables.Count > 0)
        //            {
        //                for (var i = 0; i < ds.Tables[0].Rows.Count; i++)
        //                {
        //                    li = new ListItem(ds.Tables[0].Rows[i]["WordsContent"].ToString(),
        //                        ds.Tables[0].Rows[i]["WordsValue"].ToString());
        //                    ddl.Items.Add(li);
        //                }
        //            }

        //            #endregion
        //        }

        //        public static void BindDropDownListRemarkByWordsID(int wordsID, DropDownList ddl, string DefaultStr)
        //        {
        //            #region Local Var

        //            var sql = "";
        //            var param = new SqlParameter[1];

        //            #endregion

        //            #region GetParams

        //            sql = @"   Select WordsContent,WordsID,WordsValue From S_Words
        //                       WHERE BelongID=@WordsID  and IsActive=1 order by SortID
        //                       ";

        //            param[0] = new SqlParameter("@WordsID", SqlDbType.Int);


        //            param[0].Value = wordsID;

        //            #endregion

        //            #region wangyanqing 修改

        //            //先清空DropDownList
        //            ddl.Items.Clear();

        //            var ds = SqlHelper.ExecuteDataset(PlatformConn, CommandType.Text, sql, param);
        //            ListItem li;
        //            if (ds.Tables.Count > 0)
        //            {
        //                for (var i = 0; i < ds.Tables[0].Rows.Count; i++)
        //                {
        //                    li = new ListItem(ds.Tables[0].Rows[i]["WordsValue"].ToString(),
        //                        ds.Tables[0].Rows[i]["WordsID"].ToString());
        //                    ddl.Items.Add(li);
        //                }
        //            }

        //            #endregion

        //            ddl.Items.Insert(0, new ListItem(DefaultStr, "0")); //default str
        //        }

        //        /// <summary>
        //        ///     判断账号是否具有权限
        //        /// </summary>
        //        /// <param name="account"></param>
        //        /// <param name="permissId"></param>
        //        /// <returns></returns>
        //        public static bool IsAccountHavePermissionId(string account, string permissId)
        //        {
        //            int? res = 0;
        //            SpHelper.P_ISAccountHavePermissionID(account, permissId, out res, null);

        //            return res == 1;
        //        }

        //        /// <summary>
        //        ///     Sql事务 回调函数，可以不写try catch代码 add
        //        /// </summary>
        //        /// <param name="func">Func</param>
        //        /// <returns></returns>
        //        public static bool InvokeSqlTransaction(Func<SqlTransaction, bool> func)
        //        {
        //            var result = false;
        //            using (var conn = new SqlConnection(ConfigHelper.PlatformConnString))
        //            {
        //                conn.Open();
        //                var tran = conn.BeginTransaction(IsolationLevel.ReadCommitted);

        //                try
        //                {
        //                    result = func(tran);
        //                    if (result)
        //                    {
        //                        tran.Commit();
        //                    }
        //                    else
        //                    {
        //                        tran.Rollback();
        //                    }
        //                }
        //                catch (Exception)
        //                {
        //                    tran.Rollback();
        //                    return false;
        //                }
        //            }
        //            return result;
        //        }

        //        /// <summary>
        //        /// </summary>
        //        /// <param name="I_SID"></param>
        //        /// <param name="I_KID"></param>
        //        /// <param name="I_LiuChengID"></param>
        //        /// <param name="trans"></param>
        //        /// <returns></returns>
        //        public static bool JueLuNextStep(int? I_SID, int? I_KID, int? I_LiuChengID, SqlTransaction trans)
        //        {
        //            var i = 0;
        //            var storedParams = SqlHelperParameterCache.GetSpParameterSet(ConfigHelper.PlatformConnString, "H_ZiDongQDLC");
        //            storedParams[0].Value = I_SID;
        //            storedParams[1].Value = I_KID;
        //            storedParams[2].Value = I_LiuChengID;
        //            if (trans == null)
        //                i = SqlHelper.ExecuteNonQuery(ConfigHelper.PlatformConnString, CommandType.StoredProcedure,
        //                    "H_ZiDongQDLC", storedParams);
        //            else
        //                i = SqlHelper.ExecuteNonQuery(trans, CommandType.StoredProcedure, "H_ZiDongQDLC", storedParams);
        //            if (i > 0)
        //                return true;
        //            return false;
        //        }

        //        /// <summary>
        //        /// </summary>
        //        /// <param name="remak"></param>
        //        /// <returns></returns>
        //        public static DataSet GetBindDropDownListUserByRemak(string remak)
        //        {
        //            var sql = "select userid,username,account from WaterGroupXZ_Platform.dbo.AS_UserInfo where Remark=@remark";
        //            var p1 = new SqlParameter("@remark", remak);
        //            return SqlHelper.ExecuteDataset(PlatformConn, CommandType.Text, sql, p1);
        //        }

        //        /// <summary>
        //        ///     绑定日志操作人
        //        /// </summary>
        //        /// <param name="ddl"></param>
        //        /// <param name="DefaultStr"></param>
        //        public static void BindDropDownListRZCZR(DropDownList ddl, string DefaultStr)
        //        {
        //            var ds = SpHelper.H_GetRiZhiCZR(null);
        //            ListItem li;
        //            if (ds != null && ds.Tables.Count > 0)
        //            {
        //                ddl.Items.Clear();
        //                for (var i = 0; i < ds.Tables[0].Rows.Count; i++)
        //                {
        //                    li = new ListItem(ds.Tables[0].Rows[i]["UserName"].ToString(),
        //                        ds.Tables[0].Rows[i]["Account"].ToString());
        //                    ddl.Items.Add(li);
        //                }

        //                ddl.Items.Insert(0, new ListItem(DefaultStr, "0"));
        //            }
        //        }

        //        #region 私有变量

        //        private static readonly BusinessTool _BusinessTool = new BusinessTool();
        //        private static readonly string PlatformConn = ConfigHelper.PlatformConnString;
        //        private static readonly string BusinessConn = ConfigHelper.PlatformConnString;

        //        #endregion

        //        #region 私有函数

        //        /// <summary>
        //        ///     根据 datatable的结构绑定空表头
        //        /// </summary>
        //        /// <param name="gridView"></param>
        //        /// <param name="dt"></param>
        //        private void BuildNoRecords(GridView gridView, DataTable dt)
        //        {
        //            if (gridView.Rows.Count == 0)
        //            {
        //                dt.Clear();
        //                var tmp = dt;
        //                var dr = tmp.NewRow();
        //                tmp.Rows.Add(dr);
        //                SetDefaultValue(tmp);
        //                gridView.DataSource = tmp;
        //                gridView.DataBind();
        //                var columnCount = gridView.Rows[0].Cells.Count;
        //                gridView.Rows[0].Cells.Clear();
        //                gridView.Rows[0].Cells.Add(new TableCell());
        //                gridView.Rows[0].Cells[0].ColumnSpan = columnCount;
        //                gridView.Rows[0].Cells[0].Text = "没有数据";
        //            }
        //            dt.Clear();
        //        }

        //        /// <summary>
        //        ///     根据实体绑定空表头
        //        /// </summary>
        //        /// <param name="gridView"></param>
        //        /// <param name="entity"></param>
        //        /// <param name="isEntity"></param>
        //        private void BuildNoRecords(GridView gridView, object entity, bool isEntity)
        //        {
        //            var gvv = gridView.Visible;
        //            if (gridView.Rows.Count == 0)
        //            {
        //                var tmp = new DataTable();
        //                var t = entity.GetType();
        //                var _PropertyInformation = t.GetProperties();
        //                for (var i = 0; i <= _PropertyInformation.Length - 1; i++)
        //                {
        //                    if (_PropertyInformation[0].MemberType == MemberTypes.Property)
        //                    {
        //                        if (_PropertyInformation[i].Name == "IsBlankOut")
        //                        {
        //                            Debug.WriteLine("tr2" + DateTime.Now);
        //                        }
        //                        try
        //                        {
        //                            if (_PropertyInformation[i].PropertyType.Name != "Nullable`1")
        //                                tmp.Columns.Add(_PropertyInformation[i].Name, _PropertyInformation[i].PropertyType);
        //                            else if (_PropertyInformation[i].PropertyType.ToString() ==
        //                                     "System.Nullable`1[System.DateTime]")
        //                                tmp.Columns.Add(_PropertyInformation[i].Name, typeof (DateTime));
        //                            else if (_PropertyInformation[i].PropertyType.ToString() ==
        //                                     "System.Nullable`1[System.Int16]")
        //                                tmp.Columns.Add(_PropertyInformation[i].Name, typeof (short));
        //                            else if (_PropertyInformation[i].PropertyType.ToString() ==
        //                                     "System.Nullable`1[System.Boolean]")
        //                                tmp.Columns.Add(_PropertyInformation[i].Name, typeof (bool));
        //                            else if (_PropertyInformation[i].PropertyType.ToString() ==
        //                                     "System.Nullable`1[System.Int32]")
        //                                tmp.Columns.Add(_PropertyInformation[i].Name, typeof (int));
        //                            else if (_PropertyInformation[i].PropertyType.ToString() ==
        //                                     "System.Nullable`1[System.Decimal]")
        //                                tmp.Columns.Add(_PropertyInformation[i].Name, typeof (decimal));
        //                            else if (_PropertyInformation[i].PropertyType.ToString() ==
        //                                     "System.Nullable`1[System.Double]")
        //                                tmp.Columns.Add(_PropertyInformation[i].Name, typeof (double));
        //                            else if (_PropertyInformation[i].PropertyType.ToString() ==
        //                                     "System.Nullable`1[System.Byte]")
        //                                tmp.Columns.Add(_PropertyInformation[i].Name, typeof (byte));
        //                        }
        //                        catch
        //                        {
        //                        }
        //                    }
        //                }
        //                var _DataRow = tmp.NewRow();
        //                tmp.Rows.Add(_DataRow);
        //                SetDefaultValue(tmp);
        //                gridView.DataSource = tmp;
        //                gridView.DataBind();
        //                var columnCount = gridView.Rows[0].Cells.Count;
        //                gridView.Rows[0].Cells.Clear();
        //                gridView.Rows[0].Cells.Add(new TableCell());
        //                gridView.Rows[0].Cells[0].ColumnSpan = columnCount;
        //                gridView.Rows[0].Cells[0].Text = "没有数据";
        //                gridView.Rows[0].Attributes["onclick"] = "";
        //                gridView.Visible = true;
        //            }
        //        }

        /// <summary>
        ///     给datatable的第一行赋予默认值
        /// </summary>
        /// <param name="tmpdt"></param>
        private static void SetDefaultValue(DataTable tmpdt)
        {
            for (var i = 0; i <= tmpdt.Columns.Count - 1; i++)
            {
                var t = tmpdt.Columns[i].DataType;
                try
                {
                    tmpdt.Rows[0][i] = RetTypeDefaultValue(t);
                }
                catch
                {
                }
            }
        }

        /// <summary>
        ///     得到一个类型的默认值
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        private static object RetTypeDefaultValue(Type t)
        {
            switch (t.Name)
            {
                case "Object":
                    return null;
                case "Byte":
                    return (byte)1;
                case "Boolean":
                    return true;
                case "Int16":
                    return 1;
                case "Double":
                    return 1d;
                case "DateTime":
                    return DateTime.Now;
                case "String":
                    return "0";
                case "Decimal":
                    return 1m;
                case "Int32":
                    return 1;
                default:
                    return "";
            }
        }

        //        #endregion

        //        #region 文件上传

        //        /// <summary>
        //        ///     远程打通方法
        //        /// </summary>
        //        /// <param name="command"></param>
        //        /// <returns></returns>
        //        public static string RunCmd(string command)
        //        {
        //            var process = new Process();
        //            process.StartInfo.FileName = "cmd.exe";
        //            process.StartInfo.Arguments = "/c " + command;
        //            process.StartInfo.UseShellExecute = false;
        //            process.StartInfo.RedirectStandardInput = true;
        //            process.StartInfo.RedirectStandardOutput = true;
        //            process.StartInfo.RedirectStandardError = true;
        //            process.StartInfo.CreateNoWindow = true;
        //            process.Start();
        //            return process.StandardOutput.ReadToEnd();
        //        }

        //        /// <summary>
        //        ///     下载
        //        /// </summary>
        //        /// <param name="CurrentPath">远程文件路径</param>
        //        public static void GiveMeFile(string CurrentPath)
        //        {
        //            #region GetFileServer

        //            var FileServer = KeyValueHelper.GetValue("FileServer");
        //            var FileServerArr = FileServer.Split(',');
        //            var FileServerIp = FileServerArr[0];
        //            var FileServerUser = FileServerArr[1];
        //            var FileServerPassword = FileServerArr[2];

        //            #endregion

        //            #region pass path

        //            var p = new Process();

        //            p.StartInfo.FileName = "cmd ";

        //            p.StartInfo.Arguments = "/C  net use " + FileServerIp + " " + FileServerPassword + " /user:" +
        //                                    FileServerUser + " ";

        //            p.StartInfo.UseShellExecute = false;

        //            p.StartInfo.RedirectStandardInput = true;

        //            p.StartInfo.RedirectStandardOutput = true;

        //            p.StartInfo.RedirectStandardError = true;

        //            p.StartInfo.CreateNoWindow = true;

        //            p.Start();

        //            Debug.WriteLine(p.StandardOutput.ReadToEnd());

        //            p.Close();

        //            #endregion

        //            #region getHttpContext

        //            var context = HttpContext.Current;

        //            #endregion

        //            #region GetFile

        //            context.Response.ContentType = "application/octet-stream";
        //            context.Response.Charset = "UTF-8";
        //            context.Response.AddHeader(
        //                "Content-Disposition",
        //                "attachment;filename=" +
        //                context.Server.UrlEncode
        //                    (
        //                        CurrentPath.Split('\\')[CurrentPath.Split('\\').Length - 1]
        //                    ).Replace("+", "%20")
        //                );
        //            context.Response.TransmitFile(CurrentPath);
        //            context.Response.End();

        //            #endregion
        //        }

        //        public static void GiveTmpFile(string CurrentPath, string saveFileName)
        //        {
        //            #region getHttpContext

        //            var context = HttpContext.Current;

        //            #endregion

        //            if (string.IsNullOrEmpty(saveFileName))
        //            {
        //                saveFileName = HttpUtility.UrlEncode(CurrentPath.Split('\\')[CurrentPath.Split('\\').Length - 1]
        //                    .Replace("+", "%20"), Encoding.UTF8);
        //            }
        //            else
        //            {
        //                saveFileName = HttpUtility.UrlEncode(saveFileName, Encoding.UTF8);
        //            }

        //            //以字符流的形式下载文件
        //            var fs = new FileStream(CurrentPath, FileMode.Open);

        //            var bytes = new byte[(int) fs.Length];
        //            fs.Read(bytes, 0, bytes.Length);
        //            fs.Close();

        //            //if (File.Exists(CurrentPath))
        //            //    File.Delete(CurrentPath);

        //            context.Response.ContentType = "application/octet-stream";
        //            //通知浏览器下载文件而不是打开
        //            context.Response.AddHeader(
        //                "Content-Disposition",
        //                "attachment;filename=" +
        //                saveFileName
        //                );

        //            context.Response.BinaryWrite(bytes);
        //            context.Response.Flush();
        //            context.Response.End();
        //        }

        //        #endregion

        //        #region Brant

        //        /// <summary>
        //        ///     下拉框复制
        //        /// </summary>
        //        /// <param name="target">目标 下拉框</param>
        //        /// <param name="source">源 下拉框</param>
        //        public static void DropDownListCopy(DropDownList target, DropDownList source)
        //        {
        //            ListItem listItem;
        //            foreach (ListItem li in source.Items)
        //            {
        //                listItem = new ListItem(li.Text, li.Value);
        //                target.Items.Add(listItem);
        //            }
        //        }

        /// <summary>
        ///     属性 copy
        /// </summary>
        /// <param name="tagetClass">目标类</param>
        /// <param name="sourceClass">数据类</param>
        /// <returns></returns>
        public static bool PropertiesCopy(object tagetClass, object sourceClass)
        {
            return PropertiesCopy(tagetClass, sourceClass, false);
        }

        /// <summary>
        ///     属性 copy
        /// </summary>
        /// <param name="tagetClass">目标类</param>
        /// <param name="sourceClass">数据类</param>
        /// <param name="ignoreCase">忽略大小写</param>
        /// <returns>属性 copy是否成功</returns>
        public static bool PropertiesCopy(object tagetClass, object sourceClass, bool ignoreCase)
        {
            try
            {
                var tagetPropertyInfos = tagetClass.GetType().GetProperties();
                var sourcePropertyInfos = sourceClass.GetType().GetProperties();
                object valueTemp;
                bool flage;
                foreach (var propertyInfo1 in tagetPropertyInfos)
                {
                    valueTemp = null;
                    flage = false;
                    foreach (var propertyInfo2 in sourcePropertyInfos)
                    {
                        if (propertyInfo2.Name.Equals(propertyInfo1.Name,
                            ignoreCase ? StringComparison.CurrentCultureIgnoreCase : StringComparison.CurrentCulture))
                        {
                            valueTemp = propertyInfo2.GetValue(sourceClass, null);
                            flage = true;
                            break;
                        }
                    }
                    if (flage)
                    {
                        var typeValueTaget = propertyInfo1.PropertyType;
                        Type typeValue = null;
                        if (null == valueTemp)
                        {
                            if (!typeValueTaget.IsGenericType)
                                continue;
                            propertyInfo1.SetValue(tagetClass, valueTemp, null);
                        }
                        else
                        {
                            typeValue = valueTemp.GetType();
                            if (typeValueTaget != typeValue)
                            {
                                if (typeValue.IsGenericType)
                                    typeValue = typeValue.GetGenericArguments()[0];
                                propertyInfo1.SetValue(tagetClass, Convert.ChangeType(valueTemp, typeValue), null);
                            }
                            else
                            {
                                propertyInfo1.SetValue(tagetClass, valueTemp, null);
                            }
                        }
                    }
                }

                return true;
            }
            catch (Exception e)
            {
                var message = e.Message;
                return false;
            }
        }

        /// <summary>
        ///     属性 copy
        /// </summary>
        /// <param name="tagetClass">目标类</param>
        /// <param name="sourceClass">数据类</param>
        /// <param name="ignoreCase">忽略大小写</param>
        /// <param name="prpertyNames">属性名称</param>
        /// <param name="isException">忽略或只</param>
        /// <returns>属性 copy是否成功</returns>
        public static bool PropertiesCopy(object tagetClass, object sourceClass, bool ignoreCase,
            List<string> prpertyNames, bool isException)
        {
            try
            {
                var tagetPropertyInfos = tagetClass.GetType().GetProperties();
                var sourcePropertyInfos = sourceClass.GetType().GetProperties();
                object valueTemp;
                bool flage;
                foreach (var propertyInfo1 in tagetPropertyInfos)
                {
                    if (null != prpertyNames && !(prpertyNames.IndexOf(propertyInfo1.Name) >= 0 ^ isException))
                    {
                        continue;
                    }
                    valueTemp = null;
                    flage = false;
                    foreach (var propertyInfo2 in sourcePropertyInfos)
                    {
                        if (propertyInfo2.Name.Equals(propertyInfo1.Name,
                            ignoreCase ? StringComparison.CurrentCultureIgnoreCase : StringComparison.CurrentCulture))
                        {
                            valueTemp = propertyInfo2.GetValue(sourceClass, null);
                            flage = true;
                            break;
                        }
                    }
                    if (flage)
                    {
                        var typeValueTaget = propertyInfo1.PropertyType;
                        Type typeValue = null;
                        if (null == valueTemp)
                        {
                            if (!typeValueTaget.IsGenericType)
                                continue;
                            propertyInfo1.SetValue(tagetClass, valueTemp, null);
                        }
                        else
                        {
                            typeValue = valueTemp.GetType();
                            if (typeValueTaget != typeValue)
                            {
                                if (typeValue.IsGenericType)
                                    typeValue = typeValue.GetGenericArguments()[0];
                                propertyInfo1.SetValue(tagetClass, Convert.ChangeType(valueTemp, typeValue), null);
                            }
                            else
                            {
                                propertyInfo1.SetValue(tagetClass, valueTemp, null);
                            }
                        }
                    }
                }

                return true;
            }
            catch (Exception e)
            {
                var message = e.Message;
                return false;
            }
        }

        /// <summary>
        ///     将DataRow转换为Entity
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="row"></param>
        /// <param name="columnsName"></param>
        /// <returns></returns>
        public static T GetEntity<T>(DataRow row, List<string> columnsName) where T : new()
        {
            var obj = new T();
            try
            {
                var columnname = "";
                var value = "";
                PropertyInfo[] Properties;
                Properties = typeof(T).GetProperties();
                foreach (var objProperty in Properties)
                {
                    columnname = columnsName.Find(name => name.ToLower() == objProperty.Name.ToLower());
                    if (!string.IsNullOrEmpty(columnname))
                    {
                        value = row[columnname].ToString();
                        if (!string.IsNullOrEmpty(value))
                        {
                            if (Nullable.GetUnderlyingType(objProperty.PropertyType) != null)
                            {
                                value = row[columnname].ToString().Replace("$", "").Replace(",", "");
                                objProperty.SetValue(obj,
                                    Convert.ChangeType(value,
                                        Type.GetType(Nullable.GetUnderlyingType(objProperty.PropertyType).ToString())),
                                    null);
                            }
                            else
                            {
                                value = row[columnname].ToString().Replace("%", "");
                                objProperty.SetValue(obj,
                                    Convert.ChangeType(value, Type.GetType(objProperty.PropertyType.ToString())), null);
                            }
                        }
                    }
                }
                return obj;
            }
            catch
            {
                return obj;
            }
        }

        /// <summary>
        ///     将DataRow转换为Entity
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="row"></param>
        /// <param name="columnsName"></param>
        /// <returns></returns>
        public static T GetEntity1<T>(DataRow row, List<string> columnsName) where T : new()
        {
            var obj = new T();
            try
            {
                var columnname = "";
                var value = "";
                PropertyInfo[] Properties;
                Properties = typeof(T).GetProperties();
                foreach (var objProperty in Properties)
                {
                    columnname = columnsName.Find(name => name.ToLower() == objProperty.Name.ToLower());
                    if (!string.IsNullOrEmpty(columnname))
                    {
                        value = row[columnname].ToString();
                        if (!string.IsNullOrEmpty(value))
                        {
                            if (Nullable.GetUnderlyingType(objProperty.PropertyType) != null)
                            {
                                value = row[columnname].ToString().Replace("$", "").Replace(",", "");
                                objProperty.SetValue(obj,
                                    Convert.ChangeType(value,
                                        Type.GetType(Nullable.GetUnderlyingType(objProperty.PropertyType).ToString())),
                                    null);
                            }
                            else
                            {
                                value = row[columnname].ToString();
                                objProperty.SetValue(obj,
                                    Convert.ChangeType(value, Type.GetType(objProperty.PropertyType.ToString())), null);
                            }
                        }
                    }
                }
                return obj;
            }
            catch
            {
                return obj;
            }
        }

        /// <summary>
        ///     将DataRow转换为Entity
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="row"></param>
        /// <param name="columnsName"></param>
        /// <returns></returns>
        public static T GetEntityNew<T>(DataRow row, List<string> columnsName) where T : new()
        {
            var obj = new T();
            try
            {
                var columnname = "";
                var value = "";
                PropertyInfo[] Properties;
                Properties = typeof(T).GetProperties();
                foreach (var objProperty in Properties)
                {
                    columnname = columnsName.Find(name => name.ToLower() == objProperty.Name.ToLower());
                    if (!string.IsNullOrEmpty(columnname))
                    {
                        value = row[columnname].ToString();
                        if (!string.IsNullOrEmpty(value))
                        {
                            if (Nullable.GetUnderlyingType(objProperty.PropertyType) != null)
                            {
                                value = row[columnname].ToString();
                                objProperty.SetValue(obj,
                                    Convert.ChangeType(value,
                                        Type.GetType(Nullable.GetUnderlyingType(objProperty.PropertyType).ToString())),
                                    null);
                            }
                            else
                            {
                                value = row[columnname].ToString();
                                objProperty.SetValue(obj,
                                    Convert.ChangeType(value, Type.GetType(objProperty.PropertyType.ToString())), null);
                            }
                        }
                    }
                }
                return obj;
            }
            catch
            {
                return obj;
            }
        }

        /// <summary>
        ///     将Entity增加到表
        /// </summary>
        /// <typeparam name="T">实体类型</typeparam>
        /// <param name="dt">表</param>
        /// <param name="entity">实体</param>
        public static void EntityAddToDataTable<T>(DataTable dt, T entity)
        {
            var newDataTable = new DataTable();
            var impliedType = typeof(T);
            var _propInfo = impliedType.GetProperties();
            var dr = dt.NewRow();
            dr.BeginEdit();
            foreach (var pi in _propInfo)
            {
                try
                {
                    dr[pi.Name] = pi.GetValue(entity, null);
                }
                catch
                {
                }
            }
            dr.EndEdit();
            dt.Rows.Add(dr);
        }

        /// <summary>
        ///     类值copy
        ///     tagetClass 和 sourceClass 类相同
        /// </summary>
        /// <param name="tagetClass">目标类</param>
        /// <param name="sourceClass">数据类</param>
        /// <returns>成功 或 失败</returns>
        public static bool ClassCopy(object tagetClass, object sourceClass)
        {
            if (tagetClass.GetType().Equals(sourceClass.GetType()))
            {
                try
                {
                    var propertyInfos = tagetClass.GetType().GetProperties();
                    foreach (var propertyInfo in propertyInfos)
                    {
                        propertyInfo.SetValue(tagetClass, propertyInfo.GetValue(sourceClass, null), null);
                    }
                    return true;
                }
                catch
                {
                    return false;
                }
            }
            return false;
        }

        /// <summary>
        ///     表格查询 返回表格
        /// </summary>
        /// <param name="resTable"></param>
        /// <param name="filter"></param>
        /// <param name="storStr"></param>
        /// <returns></returns>
        public static DataTable TableSelect(DataTable resTable, string filter, string storStr)
        {
            var retTable = resTable.Clone();
            DataRow dataRow;
            foreach (var dr in resTable.Select(filter, storStr))
            {
                dataRow = retTable.NewRow();
                foreach (DataColumn dc in resTable.Columns)
                {
                    dataRow[dc.Caption] = dr[dc.Caption];
                }
                retTable.Rows.Add(dataRow);
            }
            return retTable;
        }

        /// <summary>
        ///     获取 下拉框的值 binding
        /// </summary>
        /// <param name="ddl">下拉框</param>
        /// <param name="value">值</param>
        /// <returns>显示</returns>
        public static string getDDLTextByValue(DropDownList ddl, object value)
        {
            if (null == value)
            {
                return string.Empty;
            }
            var li = ddl.Items.FindByValue(value.ToString());
            if (null == li)
            {
                return string.Empty;
            }
            if (li.Text != _ddlDefaultStr)
            {
                return li.Text;
            }
            return string.Empty;
        }

        public static string getDDLValueByText(DropDownList ddl, object text)
        {
            if (null == text)
            {
                return string.Empty;
            }
            var li = ddl.Items.FindByText(text.ToString());
            if (null == li)
            {
                return string.Empty;
            }
            if (li.Text != _ddlDefaultStr)
            {
                return li.Value;
            }
            return string.Empty;
        }



        //        /// <summary>
        //        ///     脚本alert
        //        /// </summary>
        //        /// <param name="page"></param>
        //        /// <param name="msg"></param>
        //        public static void ScriptAlert(Page page, string msg)
        //        {
        //            page.ClientScript.RegisterStartupScript(typeof (Page), "alert", "$(function(){alert('" + msg + "');});",
        //                true);
        //        }

        /// <summary>
        ///     批量数据 更新
        /// </summary>
        /// <param name="dataTable">数据</param>
        /// <param name="tableName">表名</param>
        public static bool UpdateData(DataTable dataTable, string primaryKey, string tableName)
        {
            try
            {
                var sb = new StringBuilder();
                foreach (DataRow dr in dataTable.Rows)
                {
                    sb.Append("'" + dr[primaryKey] + "',");
                }
                sb.Remove(sb.Length - 1, 1);
                var dtTemp = new DataTable();

                var sqlDataAdapter =
                    new SqlDataAdapter("select * from " + tableName + " where " + primaryKey + " in(" + sb + ")"
                        , ConfigHelper.PlatformConnString);
                var sqlCommandBuilder = new SqlCommandBuilder(sqlDataAdapter);
                sqlDataAdapter.Fill(dtTemp);
                for (var i = 0; i < dtTemp.Rows.Count; i++)
                {
                    for (var j = 0; j < dtTemp.Columns.Count; j++)
                    {
                        dtTemp.Rows[i][j] = dataTable.Rows[i][j];
                    }
                }
                sqlDataAdapter.UpdateCommand = sqlCommandBuilder.GetUpdateCommand();
                sqlDataAdapter.Update(dtTemp);
                return true;
            }
            catch (Exception ex)
            {
                SystemLog.SaveLogInfo(ex.Message, "UpdateData", "BusinessTool");
                return false;
            }
        }

        /// <summary>
        ///     批量数据 导入
        /// </summary>
        /// <param name="dataTable">数据</param>
        /// <param name="tableName">表名</param>
        public static bool InsertData(DataTable dataTable, string tableName)
        {
            using (var destinationConnection = new SqlConnection(ConfigHelper.PlatformConnString))
            {
                destinationConnection.Open();
                using (var bulkCopy = new SqlBulkCopy(destinationConnection))
                {
                    bulkCopy.DestinationTableName = tableName;

                    try
                    {
                        if (dataTable.Columns.IndexOf("RowNumber") == dataTable.Columns.Count - 1)
                        {
                            dataTable.Columns.RemoveAt(dataTable.Columns.Count - 1);
                        }

                        bulkCopy.WriteToServer(dataTable);
                        return true;
                    }
                    catch (Exception ex)
                    {
                        SystemLog.SaveLogInfo(ex.Message, "InsertData", "BusinessTool");
                        return false;
                    }
                }
            }
        }
        /// <summary>
        ///    oracle 批量数据 导入
        /// </summary>
        /// <param name="dataTable">数据</param>
        /// <param name="tableName">表名</param>
        public static bool InsertOracelData(DataTable dataTable, string tableName)
        {
            try
            {
                InsertOracelDataThrow(dataTable, tableName);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
        public static void InsertOracelDataThrow(DataTable dataTable, string tableName)
        {
            using (var destinationConnection = new OracleConnection(ConfigHelper.PlatformConnString))
            {
                destinationConnection.Open();
                using (var bulkCopy = new OracleBulkCopy(destinationConnection))
                {
                    bulkCopy.DestinationTableName = tableName;

                    try
                    {
                        if (dataTable.Columns.IndexOf("RowNumber") == dataTable.Columns.Count - 1)
                        {
                            dataTable.Columns.RemoveAt(dataTable.Columns.Count - 1);
                        }
                        foreach (DataColumn col in dataTable.Columns)
                        {
                            bulkCopy.ColumnMappings.Add(col.ColumnName, col.ColumnName);
                        }
                        bulkCopy.WriteToServer(dataTable);
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                    finally
                    {
                        destinationConnection.Close();
                        destinationConnection.Dispose();
                        bulkCopy.Close();
                        bulkCopy.Dispose();
                    }
                }
            }
        }
        /// <summary>
        ///     binding DDL
        /// </summary>
        /// <param name="dropDownList"></param>
        /// <param name="dataTable"></param>
        /// <param name="text"></param>
        /// <param name="value"></param>
        /// <param name="defaultStr"></param>
        public static void BindDDLDataTable(DropDownList dropDownList, DataTable dataTable, string text, string value,
            string defaultText, string defaultValue)
        {
            dropDownList.DataSource = dataTable;
            dropDownList.DataTextField = text;
            dropDownList.DataValueField = value;
            dropDownList.DataBind();
            dropDownList.Items.Insert(0, new ListItem(defaultText, defaultValue));
        }

        /// <summary>
        ///     将datarow转Entity
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static T ConvertDataRow<T>(DataRow dr) where T : new()
        {
            var type = typeof(T);
            if (dr == null)
                return default(T);
            var obj = new T();
            for (var i = 0; i < dr.Table.Columns.Count; i++)
            {
                var o = dr[i];
                var name = dr.Table.Columns[i].ColumnName;
                if (o != DBNull.Value)
                {
                    try
                    {
                        //给属性赋值


                        var t = type.GetProperty(name).PropertyType;

                        if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Nullable<>))
                            t = t.GetGenericArguments()[0];


                        type.GetProperty(name).SetValue(obj, Convert.ChangeType(o, t), null);
                    }
                    catch //如果有错误,继续下一个属性的赋值   
                    {
                    }
                }
            }
            return obj;
        }

        public static T ConvertToEntity<T>(DataTable dt) where T : new()
        {
            var dataRow = dt.Rows[0];
            return ConvertDataRow<T>(dataRow);
        }

        public static List<T> ConvertDataTable<T>(DataTable dt) where T : new()
        {
            var objList = new List<T>();

            foreach (DataRow dr in dt.Rows)
            {
                objList.Add(ConvertDataRow<T>(dr));
            }

            return objList;
        }

        // <summary>
        /// enable or disable the control's contorls(one level)
        /// </summary>
        /// <param name="container"></param>
        /// <param name="enable"></param>
        public static void ControlEnable(Control container, bool enable)
        {
            foreach (Control var in container.Controls)
            {
                if (var is TextBox)
                {
                    ((TextBox)var).Enabled = enable;
                }
                if (var is CheckBox) { ((CheckBox)var).Enabled = enable; }
                if (var is DropDownList) { ((DropDownList)var).Enabled = enable; }
                if (var is CalendarPicker) { ((CalendarPicker)var).Enabled = enable; }
                if (var is Button)
                {
                    ((Button)var).Enabled = enable;
                }
                if (var is HtmlInputButton)
                {
                    if (!enable)
                    {
                        ((HtmlInputButton)var).Attributes["disabled"] = "'disabled'";
                    }
                    else
                    {
                        ((HtmlInputButton)var).Attributes.Remove("disabled");
                    }
                }

                #region process GridView
                else if (var is GridView)
                {
                    GridView gv = ((GridView)var);//遍历到的GV
                    DataControlFieldCollection _DataControlFieldCollection = gv.Columns;//GV的列集合
                    for (int i = 0; i < _DataControlFieldCollection.Count; i++)//遍历gv的列
                    {
                        DataControlField _DataControlField = _DataControlFieldCollection[i];
                        bool currentState = enable;//GRIDVIEW中控件用的状态
                        for (int n = 0; n < gv.Rows.Count; n++)//遍历这列中的行
                        {
                            if (gv.Rows[n].RowType == DataControlRowType.DataRow)//如果是真行的话
                            {
                                foreach (Control item in gv.Rows[n].Cells[i].Controls)//遍历这行单元格中的控件
                                {
                                    if (item is LinkButton)
                                    {
                                        ((LinkButton)item).Enabled = currentState;
                                        ((LinkButton)item).OnClientClick = "";
                                    }
                                    else if (item is Button)
                                    {
                                        ((Button)item).Enabled = currentState;
                                        ((Button)item).OnClientClick = "";
                                    }
                                    else if (item is CheckBox)
                                    {
                                        ((CheckBox)item).Enabled = currentState;
                                        ((CheckBox)item).Attributes["onclick"] = "";
                                    }
                                }
                            }
                        }
                    }
                    return;//如果是grid直接return
                }
                #endregion
                ControlEnable(var, enable);
            }
        }

        ///<summary>
        /// 根据datatable的结构绑定空表头
        /// </summary>
        /// <param name="gridView"></param>
        /// <param name="dt"></param>
        private static void BuildNoRecords(GridView gridView, DataTable dt)
        {
            //   DevExpress.Web.ASPxGridView.ASPxGridView a = new DevExpress.Web.ASPxGridView.ASPxGridView();
            //   a.VisibleRowCount; 
            if (gridView.Rows.Count == 0)
            {

                dt.Clear();
                DataTable tmp = dt;
                DataRow dr = tmp.NewRow();
                tmp.Rows.Add(dr);
                SetDefaultValue(tmp);
                gridView.DataSource = tmp;
                gridView.DataBind();
                int columnCount = gridView.Rows[0].Cells.Count;
                gridView.Rows[0].Cells.Clear();
                gridView.Rows[0].Cells.Add(new TableCell());
                gridView.Rows[0].Cells[0].ColumnSpan = columnCount;
                gridView.Rows[0].Cells[0].Text = "没有数据";
                gridView.Rows[0].Cells[0].Attributes["NoRecord"] = "true";
            }
            else if (gridView.Rows[0].Cells[0].Attributes["NoRecord"] != null)
            {
                dt.Clear();
                DataTable tmp = dt;
                DataRow dr = tmp.NewRow();
                tmp.Rows.Add(dr);
                SetDefaultValue(tmp);
                gridView.DataSource = tmp;
                gridView.DataBind();
                int columnCount = gridView.Rows[0].Cells.Count;
                gridView.Rows[0].Cells.Clear();
                gridView.Rows[0].Cells.Add(new TableCell());
                gridView.Rows[0].Cells[0].ColumnSpan = columnCount;
                gridView.Rows[0].Cells[0].Text = "没有数据";
                gridView.Rows[0].Cells[0].Attributes["NoRecord"] = "true";
            }

        }


        public static void BuildNoRecords(GridView GV, object DataSource)
        {
            if (GV.Rows.Count == 0 || GV.Rows[0].Cells[0].Text == "没有数据")
            {
                if (DataSource is DataSet)
                {
                    BuildNoRecords(GV, ((DataSet)DataSource).Tables[0]);
                }
                else if (DataSource is DataTable)
                {
                    BuildNoRecords(GV, ((DataTable)DataSource));
                }
            }
        }

        /// <summary>
        /// 根据ID获取对应表的行记录
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="id">主键ID</param>
        /// <returns>表的行记录</returns>
        public static DataTable GetDataTable(string tableName, int id)
        {
            string spName = "CS_Sel" + tableName;
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(Platform.Configuration.ConfigHelper.PlatformConnString, spName);
            storedParams[0].Value = id;
            DataSet ds = OracleHelper.ExecuteDataset(Platform.Configuration.ConfigHelper.PlatformConnString, CommandType.StoredProcedure, spName, storedParams);
            if (null == ds)
            {
                return null;
            }
            else
                return ds.Tables[0];
        }

        /// <summary>
        /// 获取数据库服务器当前的日期和时间
        /// </summary>
        /// <returns>数据库系统的日期时间</returns>
        public static DateTime GetDataBaseDateTime()
        {
            int? error = 0;
            DataTable dt = _spHelper.COMMON_SELECTANYTABLE("SYSDATE", "DUAL", null, null, null, out error).Tables[0];
            DataRow dr = dt.Rows[0];
            return Convert.ToDateTime(dr["SYSDATE"]);             // 生效日期
        }

        /// <summary>
        /// 根据当前ID获取下月数据记录
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="id"></param>
        /// <param name="tableName"></param>
        /// <param name="columnName"></param>
        /// <returns></returns>
        public static T GetNextDataEntityByID<T>(int id, string tableName, string columnName) where T : new()
        {
            T t = new T();
            var ds = _spHelper.P_GETNEXTBYCURRENTID(id, tableName, columnName);
            if (null == ds) return t;
            if (ds.Tables.Count == 0) return t;
            t = ConvertToEntity<T>(ds.Tables[0]);
            return t;
        }
        public static DataSet GetViewYS_JX_ZILAISGSSJSZ()
        {
            return _spHelper.P_VIEW_YS_ZILAISGSSJSZ();
        }
        public static DataSet GetViewYS_JX_BUMENXX()
        {
            return _spHelper.P_VIEW_YS_BUMENXX();
        }
        /// <summary>
        /// 查询指定表中的两列作为数据源
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="textName">映射为TEXT列的目标列名</param>
        /// <param name="valueName">映射为VALUE列的目标列名</param>
        /// <param name="splitChar">分隔符 如果不为NULL 实际返回的TEXT为:VALUE+分隔符+TEXT的值[如:01-虹口] 为NULL则返回TEXT列的值</param>
        /// <param name="condition">查询条件 不包含WHERE</param>
        /// <returns></returns>
        public static DataSet GetTextAndValue(string tableName, string textName, string valueName, string splitChar, string condition)
        {
            return _spHelper.P_COMMON_GETTEXTANDVALUE(tableName, textName, valueName, null, splitChar, condition, null);
        }
        /// <summary>
        /// 查询指定表中的两列作为数据源
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="textName">映射为TEXT列的目标列名</param>
        /// <param name="valueName">映射为VALUE列的目标列名</param>
        /// <param name="splitChar">分隔符 如果不为NULL 实际返回的TEXT为:VALUE+分隔符+TEXT的值[如:01-虹口] 为NULL则返回TEXT列的值</param>
        /// <param name="condition">查询条件 不包含WHERE</param>
        /// <param name="orderColumn">排序列:ID ASC</param>
        /// <returns></returns>
        public static DataSet GetTextAndValue(string tableName, string textName, string valueName, string splitChar, string condition, string orderColumn)
        {
            return _spHelper.P_COMMON_GETTEXTANDVALUE(tableName, textName, valueName, null, splitChar, condition, orderColumn);
        }

        public static DataSet GetTextAndValueAndSelectColumns(string tableName, string textName, string valueName, string selectColumns, string splitChar, string condition, string orderColumn)
        {
            return _spHelper.P_COMMON_GETTEXTANDVALUE(tableName, textName, valueName, selectColumns, splitChar, condition, orderColumn);
        }

        public static DataSet GetUsersByRole(string zhandian, string roleName, string department)
        {
            return _spHelper.P_GETUSERSBYROLE(zhandian, roleName, department);
        }

        /// <summary>
        /// 查询指定表历史数据
        /// </summary>
        /// <param name="tableName">要查历史数据的表名</param>
        /// <param name="yearMonth">要查历史数据的年月 格式:201506</param>
        /// <param name="condition">查询条件</param>
        /// <returns></returns>
        public static DataTable GETDATAHISTORY(string tableName, string yearMonth, string condition)
        {
            return _spHelper.P_COMMON_GETDATAHISTORY(tableName, yearMonth, condition).Tables[0];
        }

        /// <summary>
        /// 获取配置信息中的VALUE值
        /// </summary>
        /// <param name="keyname"></param>
        /// <returns></returns>
        public static string YS_GETSETTINGSVALUE(string keyname)
        {
            return _spHelper.P_YS_GETSETTINGSVALUE(keyname).Tables[0].Rows[0][0].ToString();
        }

        /// <summary>
        /// 获取指定表指定列的最大值
        /// </summary>
        /// <param name="V_TABLENAME">表</param>
        /// <param name="V_COLUMNNAME">列</param>
        /// <param name="V_CONDITION">条件</param>
        public static string GETMAXVALUE(string V_TABLENAME, string V_COLUMNNAME, string V_CONDITION)
        {
            return _spHelper.P_COMMON_GETMAXVALUE(V_TABLENAME, V_COLUMNNAME, V_CONDITION).Tables[0].Rows[0][0].ToString();
        }

        /// <summary>
        /// 根据操作人加载管理部门(站点)
        /// </summary>
        /// <param name="userid">操作人id</param>
        /// <returns></returns>
        public static string GETZHANDIAN(int userid)
        {
            DataTable dtZhanDian = BusinessTool.GetTextAndValue("View_AS_UserInfo", "ZHANDIANMC", "ZHANDIANBH", "-", string.Format("USERID={0}", userid)).Tables[0];
            return dtZhanDian.Rows[0]["VALUE"].ToString();
        }
        public static string GETZHANDIANMC(int userid)
        {
            DataTable dtZhanDian = BusinessTool.GetTextAndValue("View_AS_UserInfo", "ZHANDIANMC", "ZHANDIANBH", null, string.Format("USERID={0}", userid)).Tables[0];
            return dtZhanDian.Rows[0]["TEXT"].ToString();
        }

        /// <summary>
        /// 获取当前登录人站点
        /// </summary>
        /// <returns></returns>
        public static string ZHANDIANBH()
        {
            object t = HttpContext.Current.Session["ZhanDianBH"];
            if (t == null || t.ToString() == "")
            {
                t = HttpContext.Current.Session["ZhanDianBH"] = GETZHANDIAN(LoginInfo.CurrentUser.UserID);
            }
            return t.ToString();
        }
        public static string ZHANDIANMC()
        {
            object t = HttpContext.Current.Session["ZhanDianMC"];
            if (t == null || t.ToString() == "")
            {
                t = HttpContext.Current.Session["ZhanDianMC"] = GETZHANDIANMC(LoginInfo.CurrentUser.UserID);
            }
            return t.ToString();
        }

        /// <summary>
        /// 获取当前水量年月 
        /// </summary>
        /// <returns></returns>
        public static int GetWaterYM()
        {
            object t;
            t = HttpContext.Current.Session["WaterYM"];
            if (t == null || t.ToString() == "")
            {
                if (BusinessTool.WType == 0)
                {
                    t = HttpContext.Current.Session["WaterYM"] = int.Parse(BLL.BusinessTool.YS_GETSETTINGSVALUE(eSETTINGS_KEYNAME.WATER_Y_M.ToString()));
                }
                else
                {
                    t = HttpContext.Current.Session["WaterYM"] = BusinessTool.GetSLYMorZWNY(1, BusinessTool.WType);
                }
            }
            return Convert.ToInt32(t);
        }

        /// <summary>
        /// 获取当前水量年月 或者账务年月
        /// </summary>
        /// SLYMorZWYM 1水量年月 2账务年月
        /// <returns></returns>
        public static int GetSLYMorZWNY(int SLYMorZWYM, int WTYPE)
        {
            string val = "";
            _spHelper.P_QS_GETSLYMORZWNY(SLYMorZWYM, WTYPE, out val);

            return Convert.ToInt32(val);
        }
        /// <summary>
        /// 获取当前账务年月 
        /// </summary>
        /// <returns></returns>
        public static int GetZWYM()
        {

            object t = HttpContext.Current.Session["ZWYM"];
            if (t == null || t.ToString() == "")
            {
                t = HttpContext.Current.Session["ZWYM"] = int.Parse(BLL.BusinessTool.YS_GETSETTINGSVALUE(eSETTINGS_KEYNAME.ZW_Y_M.ToString()));
            }
            return Convert.ToInt32(t);
        }

        /// <summary>
        /// 获取合同号
        /// </summary>
        /// <param name="yonghuh">用户号</param>
        /// <returns></returns>
        public static string GetHeTongH(string yonghuh)
        {
            return new SpHelper().P_YS_GETHETONGH(yonghuh).Tables[0].Rows[0][0].ToString();
        }
        /// <summary>
        /// 获取水表近三月数据状态
        /// </summary>
        /// <param name="shuibiaoBH"></param>
        /// <param name="msg"></param>
        /// <returns>true:有数据 false:无数据</returns>
        public static bool GetShuiBiaoSJZT(string shuibiaoBH, out string msg)
        {
            //获取该水表是否有本月数据
            //1.查本月
            DataTable dtMonthNow = new YS_CB_SHUIBIAOXXBLL().SelectYS_CB_SHUIBIAOXXesDynamic(string.Format("S_SHUIBIAOBH='{0}' and I_LEIXING=0 ", shuibiaoBH), null);
            if (dtMonthNow.Rows.Count == 1)
            {
                string sl = Convert.ToString(dtMonthNow.Rows[0]["I_BENYUESL"]);
                //判断本月水量
                if (sl != "" && sl != "0")
                {
                    msg = "本月有水表数据。";
                    return true;
                }
            }
            msg = "无数据";
            return false;
        }
        ///// <summary>
        ///// 获取水表近三月数据状态
        ///// </summary>
        ///// <param name="shuibiaoBH"></param>
        ///// <param name="msg"></param>
        ///// <returns>true:有数据 false:无数据</returns>
        //public static bool GetShuiBiaoSJZT(string shuibiaoBH, out string msg)
        //{
        //    //获取该水表近3月是否有数据
        //    //1.查本月
        //    DataTable dtMonthNow = new YS_CB_SHUIBIAOXXBLL().SelectYS_CB_SHUIBIAOXXesDynamic(string.Format("S_SHUIBIAOBH='{0}' and I_LEIXING=0 ", shuibiaoBH), null);
        //    if (dtMonthNow.Rows.Count == 1)
        //    {
        //        string sl = Convert.ToString(dtMonthNow.Rows[0]["I_BENYUESL"]);
        //        //判断本月水量
        //        if (sl != "" && sl != "0")
        //        {
        //            msg = "本月有水表数据。";
        //            return true;
        //        }
        //    }
        //    else
        //    {
        //        //查上月水量
        //        DataTable dtMonthPre = BusinessTool.GETDATAHISTORY("YS_CB_SHUIBIAOXX", (BusinessTool.GetWaterYM() - 1).ToString(), string.Format("S_SHUIBIAOBH='{0}' and I_BENYUESL<>0", shuibiaoBH));
        //        if (dtMonthPre.Rows.Count != 0)
        //        {
        //            msg = "上月有水表数据。";
        //            return true;
        //        }
        //    }
        //    //历史表中查上上月水量
        //    DataTable dtMonthPrePre = BusinessTool.GETDATAHISTORY("YS_CB_SHUIBIAOXX", (BusinessTool.GetWaterYM() - 2).ToString(), string.Format("S_SHUIBIAOBH='{0}' and I_BENYUESL<>0", shuibiaoBH));
        //    if (dtMonthPrePre.Rows.Count != 0)
        //    {
        //        msg = "上二月有水表数据。";
        //        return true;
        //    }
        //    msg = "无数据";
        //    return false;
        //}

        #region 处理数值字符显示转换

        public static string GetStrFromValue(eStrValueMapType type, string val)
        {
            string str = "";
            if (type == eStrValueMapType.UserActive)
            {
                str = val == "1" ? "激活" : val == "0" ? "未激活" : "";
            }
            return str;
        }

        public enum eStrValueMapType
        {
            UserActive
        }

        #endregion


        public static DataTable CurrentUserGroup(int userId)
        {
            return SearchByUserGroup(userId).Tables[0];
        }

        private static DataSet SearchByUserGroup(int p)
        {
            return _spHelper.P_CURRENTUSERGROUP(p);
        }
        public static string GetYWYName(string ywy)
        {
            DataRow dr = BusinessTool.GetTextAndValue("AS_USERINFO", "USERNAME", "USERID", null, "USERID=" + ywy).Tables[0].Rows[0];
            return Convert.ToString(dr["TEXT"]);
        }
    }
}